package com.xin.di.uav.operate.mapper;

import com.xin.di.uav.operate.po.UserRolePO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserRoleMapper {

    @Delete({"<script>",
            "DELETE  FROM user_role WHERE role_id=#{roleId}",
            "</script>"})
    int deleteByRoleId(String roleId);

    @Select({"<script>",
            "select user_id,role_id from user_role where user_id in " +
                    "       <foreach item=\"id\" collection=\"ids\" open=\"(\" separator=\",\" close=\")\">\n" +
                    "            #{id}\n" +
                    "        </foreach>" +
                    "</script>"})
    List<UserRolePO> selectList(@Param("ids") List<String> ids);

    @Insert({"<script>",
            "insert into user_role (user_id, role_id)\n" +
                    "values (#{userId},#{roleId})",
            "</script>"})
    int insert(UserRolePO userRolePO);


    @Select({"<script>",
            "select role_id from user_role where user_id =#{userId} " +
                    "</script>"})
    List<String> selectByUserId(@Param("userId") String userId);
}
